package com.emagic.manage.modules.room.adapter;

import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.emagic.manage.R;
import com.emagic.manage.modules.room.view.AllRoomUser;
import com.emagic.manage.modules.room.view.ClassRoomUser;

import java.util.List;

/**
 * Created by xiatian on 2017/12/6.
 */

public class InClassUserListAdapter extends BaseQuickAdapter<AllRoomUser.RoomUser, BaseViewHolder> {
    public InClassUserListAdapter(List<AllRoomUser.RoomUser> data) {
        super(R.layout.view_user_item, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, AllRoomUser.RoomUser item) {

        helper.setText(R.id.user_name, item.getFirstname())
                .addOnClickListener(R.id.audio_img)
                .addOnClickListener(R.id.video_img)
                .addOnClickListener(R.id.draw_img);

        ImageView audio = helper.getView(R.id.audio_img);
        ImageView video = helper.getView(R.id.video_img);
        ImageView draw = helper.getView(R.id.draw_img);
        if (item.getState() == ClassRoomUser.PUBLISH_STATE_NONE) {
            audio.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.ic_class_voice));
            video.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.ic_class_video));
        } else if (item.getState() == ClassRoomUser.PUBLISH_STATE_AUDIOONLY) {
            audio.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.ic_class_voice_press));
            video.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.ic_class_video));
        } else if (item.getState() == ClassRoomUser.PUBLISH_STATE_VIDEOONLY) {
            audio.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.ic_class_voice));
            video.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.ic_class_video_press));
        } else if (item.getState() == ClassRoomUser.PUBLISH_STATE_BOTH) {
            audio.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.ic_class_voice_press));
            video.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.ic_class_video_press));
        }
        if (item.isCandraw()) {
            draw.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.ic_class_draw_press));
        } else {
            draw.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.ic_class_draw));
        }
    }
}
